// antd 按需加载
import { Toast } from '@ant-design/react-native';

import store from '../../../store/store.js'
import * as ActionTypes from '../../../constants/constants.js'
import { isUser, isWxUser, path, saveData, loadData, removeData, requstPromise } from '../../../util/utils.js'
import request from '../../../api/request.js'

export async function search(options) {
    const { dispatch } = this.props
    const { refresh, ...option } = options
    const res = await request.GoodsController.list({ ...option })

    if (res.error) {
        dispatch({
            type: ActionTypes.searchListError,
            data: res
        })
        return
    }
    if (refresh) {
        dispatch({
            type: ActionTypes.searchListRefresh,
            data: res.data.data
        })
    } else {
        dispatch({
            type: ActionTypes.searchList,
            data: res.data.data
        })
    }
    return requstPromise(res)
}

